
***************************************
*********FACTORIAL EXPERIMENT**********
***************************************

clear all
*cd "" set working directory
use "immigration_speeders.dta"



*MODELS WITH SPEEDERS NO WEIGHTS
quietly logit approved_asy i.exp_1##i.exp_2##i.exp_3

*MAIN EFFECTS
margins i.exp_1 i.exp_2 i.exp_3, post
margins, coeflegend

test  _b[0bn.exp_1]= _b[1bn.exp_1]
test  _b[0bn.exp_2]= _b[1bn.exp_2]
test  _b[0bn.exp_3]= _b[1bn.exp_3]

*3-WAY TREATMENTS INTERACTIONS
margins i.exp_1, at(exp_2=(0(1)1) exp_3=(0(1)1)) post
margins, coeflegend

*TESTS
test _b[1bn._at#0bn.exp_1]=_b[3._at#0bn.exp_1]
test _b[1bn._at#1.exp_1]=_b[3._at#1.exp_1]
test _b[1bn._at#0bn.exp_1]=_b[1bn._at#1.exp_1]

test _b[2bn._at#0bn.exp_1]=_b[4._at#0bn.exp_1]
test _b[2bn._at#1.exp_1]=_b[4._at#1.exp_1]
test _b[2bn._at#0bn.exp_1]=_b[2bn._at#1.exp_1]



*2-WAY TREATMENTS INTERACTION WITH IDEOLOGY
quietly logit approved_asy i.exp_1##i.ideo i.exp_2##i.ideo i.exp_3##i.ideo

margins, dydx(exp_1) at(ideo=(1(1)3)) post
margins, coeflegend

margins, dydx(exp_2) at(ideo=(1(1)3)) post
margins, coeflegend

margins, dydx(exp_3) at(ideo=(1(1)3)) post
margins, coeflegend

*TESTS
test _b[1.exp_1:1bn._at]=_b[1.exp_1:3._at]
test _b[1.exp_2:1bn._at]=_b[1.exp_2:3._at]
test _b[1.exp_3:1bn._at]=_b[1.exp_3:3._at]

